const CACHE_PREFIX = 'smart-park-'

export default {
  set(key, value, expire = 3600) {
    const data = {
      value,
      expire: Date.now() + expire * 1000
    }
    localStorage.setItem(CACHE_PREFIX + key, JSON.stringify(data))
  },

  get(key) {
    const data = JSON.parse(localStorage.getItem(CACHE_PREFIX + key))
    if (!data || data.expire < Date.now()) {
      this.remove(key)
      return null
    }
    return data.value
  },

  remove(key) {
    localStorage.removeItem(CACHE_PREFIX + key)
  }
} 